package com.tanhua.dubbo.api;

import com.tanhua.model.mongo.VideoGuanzhu;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

@DubboService
public class VideoGuanzhuApiImpl implements VideoGuanzhuApi {
    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public void save(VideoGuanzhu videoGuanzhu) {
    mongoTemplate.save(videoGuanzhu);
    }

    @Override
    public void delete(Long uid, Long publishUserId) {
        Criteria criteria = Criteria.where("userId").is(uid).and("publishUserId").is(publishUserId);
        Query query = Query.query(criteria);
        mongoTemplate.remove(query,VideoGuanzhu.class);

    }
}
